import requests
from config import url_cloud, headers_web


class ClassTestPaper:
    def __init__(self):
        self.url = url_cloud
        self.headers = headers_web

    @classmethod
    def post_creat_learning_test(cls, url_path: str, headers=headers_web, params=None,json=None):
        """
        @summary:创建课堂测验试卷
        @description:.云课堂老师端创建课堂测验试卷
        :param url_path:/teachingApi/v1/classtestpaper
        :param headers:Content-Type:	application/json
        :param params:validCode:验证码：&signKey=123123(md5加密)
        :param json:body:{
                            "creatorId":"", # 创建人id
                            "creatorName":"",#创建人姓名
                            "folderId":"",# 所属文件夹ID
                            "name":"",#试卷名称
                            "preparationLessonId":"",#备课包id
                            "questionList":[{
                                "id":"",# 题目id
                                "order":""# 题目序号
                                }]
                            }
        :return:
        """
        url_path = url_path + "/teachingApi/v1/classtestpaper"
        r = requests.post(url=url_path, headers=headers, params=params,json=json)
        return r

    @classmethod
    def get_learning_test_detail(cls, url_path: str, headers=headers_web, params=None,paramspath=None):
        """
        @summary:获取课堂测验卷子详情
        @description:.云课堂老师端获取课堂测验卷子详情
        :param url_path:/teachingApi/v1/classtestpaper/{id}
        :param headers:
        :param params:validCode:验证码：id=&signKey=123123(md5加密)
        :param paramspath:id:试卷id
        :return:{
                "id":"",
                "isPublic":"",
                "name":"",
                "questionList":[{
                        "message"
                    }]

                }
        """
        url_path = url_path + "/teachingApi/v1/classtestpaper/{}".format(paramspath)
        r = requests.get(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def post_filter_fill_blanks(cls, url_path: str, headers=headers_web, params=None,json=None):
        """
        @summary:根据ResourceDetailID过滤包含填空题的课堂测验
        @description:.courseApi-获取备课包老师测验（试卷）资源调用
        :param url_path:/teachingApi/v1/classtestpaper/filterfillelection
        :param headers:
        :param params:validCode:验证码：&signKey=123123(md5加密)
        :param json:body:{}
        :return:
        """
        url_path = url_path + "/teachingApi/v1/classtestpaper/filterfillelection"
        r = requests.post(url=url_path, headers=headers, params=params,json=json)
        return r
